import request from "@/utils/request"

export enum OrgSettleStatus {
  待打款 = 1,
  已打款 = 2,
  打款失败 = 3,
  '待打款(已修改资料)'= 4,
}

export interface QueryOrgSettleListParams extends PaginationParams {
  orgId?: string
  status?: OrgSettleStatus
  /** 结算 ID */
  settleId?: string
  userType:number
  /** 开始时间 */
  beginDay: string
  personId?:string
  /** 结束时间 */
  endDay: string
}

export interface OrgSettle {
  /** 结算开始日期 */
  beginDay: string
  networkFee:number
  /** 结算结束日期 */
  endDay: string
  /** 充电费用 */
  chargeMoney: number
  /** 充电电费 */
  chargeElectricMoney: number
  /** 充电税费 */
  chargeInvoiceMoney: number
  /** 充电服务费 */
  chargeServiceMoney: number
  /** 结算日期 */
  createDay: string
  /** 结算单号 */
  id: string
  settleId: string
  /** 占位税费 */
  occupyInvoiceMoney: number
  /** 占位费 */
  occupyMoney: number
  /** 公司 ID */
  orgId: number
  /** 经销商名称 */
  orgName: string
  /** 所属方分成 */
  ownerMoney: number
  /** 通道费 */
  pathMoney: number
  /** 充电量（度） */
  power: number
  /** 实际到账的抽成费用 */
  realMoney: number
  /** 场站名称 */
  stationName: string
  /** 状态 */
  status: OrgSettleStatus
  /** 运营分成 */
  workMoney: number
  /** 创建时间 */
  createTime: string
}

export async function queryOrgSettleList(params: QueryOrgSettleListParams) {
  params.userType = 2;
  return request<OrgSettle[]>('/app/manager/org/settle/list', {
    data: params,
  })
}

export async function getOrgWaitSettle(params: QueryOrgSettleListParams) {
  params.userType = 2;
  return request<OrgSettle>('/app/manager/org/settle/sum', {
    data: params,
  })
}

export interface OrgSettleOfStation {
  /** 充电电费 */
  chargeElectricMoney: number
  /** 充电税费 */
  chargeInvoiceMoney: number
  /** 充电结算费用 */
  chargeMoney: number
  /** 充电服务费 */
  chargeServiceMoney: number
  /** 结算开始日期 */
  beginDay: string
  /** 结算结束日期 */
  endDay: string
  /** 结算单号 */
  id: string
  /** 占位税费 */
  occupyInvoiceMoney: number
  /** 占位费 */
  occupyMoney: number
  /** 公司 ID */
  orgId: number
  /** 经销商名称 */
  orgName: number
  /** 所属方分成 */
  ownerMoney: number
  /** 通道费 */
  pathMoney: number
  /** 充电量(度) */
  power: number
  /** 场站 ID */
  stationId: string
  /** 场站名称 */
  stationName: string
  /** 运营分成 */
  workMoney: number
}

export async function queryOrgSettleListOfStation(params: {settleId: string} & PaginationParams) {
  return request<OrgSettleOfStation[]>('/app/manager/station/settle/list', {
    data: params,
  })
}

export async function settleConfirm(params: {settleId: string, status: OrgSettleStatus}) {
  return request('/app/manager/org/settle/confirm', {
    data: params,
  })
}
